package com.mxx.springaction;

import org.aspectj.lang.ProceedingJoinPoint;
import org.aspectj.lang.annotation.*;

/**
 * @author xiaoxu.ma
 * @date 2021/11/12 14:19
 */
@Aspect
public class Audience {

    @Pointcut("execution(* com.mxx.springaction.Performance.perform())")
    public void methods() {

    }

    @Before(value = "methods()")
    public void beforeMethod() {
        System.out.println("beforeMethod..........");
    }
//    @AfterReturning(value = "methods()", argNames = "name")
//    public void afterMethod(String name){
//        System.out.println("AfterReturning.........."+name);
//    }
//    @AfterThrowing("methods(name)")
//    public void afterThrowingMethod(String name){
//        System.out.println("afterThrowingMethod.........."+name);
//    }
//    @Around("methods(name)")
//    public void aroundThrowingMethod(ProceedingJoinPoint joinPoint,String name){
//        System.out.println("环绕前.........."+name);
//        try {
//            // 可以多次调用，实现重试逻辑
//            joinPoint.proceed();
//        } catch (Throwable throwable) {
//            throwable.printStackTrace();
//        }
//        System.out.println("环绕后.........."+name);
//    }
}
